package org.gas.barapraja.handler;

import org.gas.barapraja.db.entity.Message;

import com.logica.smpp.pdu.SubmitMultiSM;
import com.logica.smpp.pdu.SubmitSM;

public class MessageComposer {
	
	public Message compose(SubmitSM sm){
		Message msg=new Message();
		msg.setSource(sm.getSourceAddr().getAddress());
 		msg.setMsisdn(sm.getDestAddr().getAddress());
		msg.setContent(sm.getShortMessage());
		return msg;
	}
	
	public Message[] compose(SubmitMultiSM multiSM,int size){
		Message[] messages=new Message[size];
		for(int i=0;i<size;i++){
			messages[i]=new Message();
			messages[i].setSource(multiSM.getSourceAddr().getAddress());
			messages[i].setMsisdn(multiSM.getDestAddress(i).getAddress().getAddress());
			messages[i].setContent(multiSM.getShortMessage());
		}
		return messages;
	}

}
